<template>
  <div>
    
  <DataList
    :cate="cate"
    :cols="cols"
:name="name"
  :single="true"
  
    :groupCheck = "groupCheck"
  />
  </div>
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import { addMc, deleteMc, updateMc, getMc } from "@/api/名称.js";
import {findComponent} from "@/utils/ui";
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A1-1名称",
      name:'1.1 名称',
      cols: [
        { label: "学校标识码", prop: "XXDM" ,sorable:true,filter:'text' },
        { label: "学校名称(全称)", prop: "XXMC" },
        { label: "所在地区(省、自治区、直辖市)", prop: "XZ_SZDQ_SS" },
        { label: "所在城市", prop: "XZ_SZDQ_DS" },
        { label: "当前校名启用日期(年月)", prop: "DQXMQYRQ" },
        { label: "建校日期(年月)", prop: "JXNY" },
        { label: "建校基础", prop: "JXJC" },
        {
          label: "学校举办者",
          prop: "学校举办者",
          data: [
            { label: "名称(全称)", prop: "XXJBZ_MC" },
            { label: "性质", prop: "XZ_XXJBZ_XZ" },
            { label: "级别", prop: "XZ_XXJBZ_JB" }
          ]
        },

        { label: "学校性质类别", prop: "XZ_XXXZM" },
        { label: "校训", prop: "XX" },
        {
          label: "示范性高等职业院校",
          data: [
            { label: "性质", prop: "XZ_SFXGZYX_XZ" },
            { label: "级别", prop: "XZ_SFXGZYX_JB" },
            { label: "立项部门", prop: "SFXGZYX_LXBM" },
            { label: "立项日期(年)", prop: "SFXGZYX_LXRQ" }
          ]
        },
        {
          label: "评估状态",
          data: [
            {
              label: "第一轮",
              data: [
                { label: "评估日期(年月)", prop: "DYLPGNY" },
                { label: "评估结论", prop: "XZ_DYLPGJL" }
              ]
            },
            {
              label: "第二轮",
              data: [
                { label: "评估日期(年月)", prop: "DELPGNY", },
                { label: "评估结论", prop: "XZ_DELPGJL" }
              ]
            }
          ]
        },
        { label: "未接受评估", prop: "XZ_SFWPG" }
      ],
       groupCheck:[{data:["XZ_DELPGJL","DELPGNY"],desc:'请完善评估状态的第二轮的输入'},
         {data:["XZ_DYLPGJL","DYLPGNY"],desc:'请完善评估状态的第一轮的输入'},
         {data:["XZ_SFXGZYX_XZ","XZ_SFXGZYX_JB","SFXGZYX_LXBM","SFXGZYX_LXRQ"],desc:'示范性高等职业院校中【性质】、【级别】、【立项部门】和【立项日期】等字段，如果填了其中1个，其他的必须填写！'}
       ]
    };
    
  },

  methods: {
    onDlgCreated(model) {
      var schema = require("../../../../static/city.json");
      var dd = findComponent(this,"XZ_SZDQ_SS");
      var tt = schema.provinces.map(item => {
        return { label: item.name, value: item.name };
      });
      dd.$attrs.items = tt;
      //model.XZ_SZDQ_SS = dd.$attrs.items[0].value;
      //

      //
    },
    //别的页面不用复制此方法
 
    onChange(model, field, value) {
      //
  
      if (field == "XZ_SZDQ_SS") {
        var schema = require("../../../../static/city.json");
        var dd = findComponent(this,"XZ_SZDQ_DS");
        var item = schema.provinces.find(item => {
          return item.name == value;
        });
        dd.$attrs.items = item.cities.map(item => {
          return { value: item.name, label: item.name };
        });
        
        model.XZ_SZDQ_DS = dd.$attrs.items[0].value;
        
       
      }
      //
    },
    check(model, reject) {},
    async fetchData() {
      var user = getUser();
      var datas = await getMc(user.XXID,user.CJPC);
     
      return datas;
    },
    
    onadd(model) {
      //
      var temp = JSON.parse(JSON.stringify(model));
      return new Promise(async (resolve, reject) => {
      try{
       
        console.log(JSON.stringify(temp));
        var model = await addMc(temp);
        resolve(model);
      }catch(e){
        reject(e);
      }
       
      });
    },

    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
        
          console.log(JSON.stringify(temp));
          var model = await updateMc(temp);
          console.log(model)
          resolve(model);
      })
      //
    },
    ondelete(model) {
       var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
         await deleteMc(temp);
          resolve();
      })
    }
  }
};
</script>
<style>
</style>